package com.sias.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 吴文杰
 * @version 1.0
 * @createTime 2023-05-03 13:54:57
 */
public class RegExp04 {
  public static void main(String[] args) {
    String content = "我....我要....学学学学....编程Java!";
    // 1.去掉所有.
    Pattern compile = Pattern.compile("\\.");
    Matcher matcher = compile.matcher(content);
    content = matcher.replaceAll("");
    System.out.println(content);
    //2.去掉重复的字 我我要学学学学编程Java!
    // compile = Pattern.compile("(.)\\1+");
    // matcher = compile.matcher(content);
    // while (matcher.find()){
    //   System.out.println(matcher.group(0));
    // }
    // content = matcher.replaceAll("$1");
    // System.out.println(content);
    content = Pattern.compile("(.)\\1+").matcher(content).replaceAll("$1");
    System.out.println(content);
  }
}
